#define _CRT_SECURE_NO_WARNINGS 1
#include"Head.h"
class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums) {
        int left = 0, right = 0;
        int sum = 0, len = INT_MAX;
        while (right < nums.size())
        {
            sum += nums[right];
            while (sum >= target)
            {
                len = min(right - left + 1, len);
                sum -= nums[left];
                left++;
            }
            right++;
        }
        if (left == 0)
            return 0;
        else
            return len;
    }
};